package com.yingxin.yx.framework.commons.enums.task;

import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 任务名称枚举
 */

public enum DynamicTaskName {

    TEST("TEST","任务测试"),

    // 系统管理
    DESY("DESY", "部门信息同步"),
    USERSY("USERSY", "员工信息同步"),


    // 合同管理
    RZHTRBB("RZHTRBB","热轧合同日报表"),


    // 库存管理
    RZSXKCHZ1("RZSXKCHZ1", "热轧、酸洗库存汇总1"),
    RZSXKCHZ2("RZSXKCHZ2", "热轧、酸洗库存汇总2"),
    RZSXKCHZ3("RZSXKCHZ3", "热轧、酸洗库存汇总3"),
    AIST("AIST", "实际库存汇总表"),
    ZYAIST("ZYAIST","轧硬库存汇总表"),

    // 生产管理
    DXUCRBB("DXUCRBB", "镀锌车间产量单耗日报表"),
    ZYSCHZRRB("ZYSCHZRRB", "轧硬生产汇总日报表"),
    SCXQK("SCXQK","生产线工作情况"),
    ZLZWLJ("ZLZWLJ","更新轧硬质检报告成品的辊耗信息"),


    // 销售管理
    CZPB("CZPB", "取消轧硬预售卷"),
    CZPBL("CZPBL", "取消轧硬预售单"),

    ZYPRICE("ZYPRICE", "轧硬价格表"),
    DXPRICE("DXPRICE", "镀锌价格表"),
    OSISDJ("OSISDJ", "特规订货入库汇总"),

    SXCKCSCX("SXCKCSCX","酸洗出库派车超时撤销"),
    ZYCKCSCX("ZYCKCSCX","轧硬出库派车超时撤销"),

    // 财务管理
    CRPDJ("CRPDJ","客户收支余额日报表"),

    // 报表管理
    RZHTRKRBB("RZHTRKRBB", "热轧合同入库日报表"),
    RZOEMRBB("RZOEMRBB", "合同(热轧代工合同)日报表"),
    GZSCCBFX("GZSCCBFX","根据工资生成成本分析"),
    GJZLJSXXSCCB("GJZLJSXXSCCB","根据主料结算信息，生成成本分析"),
    RZCGRBB("RZCGRBB","热轧采购日报表"),
    ZYSERBB("ZYSERBB","轧硬销售异常日报表"),

    JGCSKCRJRKRBB("JGCSKCRJRKRBB","济钢城市矿产主料入库日报表"),
    JGCSKCRJSTOCK("JGCSKCRJSTOCK","济钢城市矿产合同库存日报表"),

    ZYXSCQWCL("ZYXSCQWCL","轧硬卷超期未处理"),

    RZOEMZYRKRBB("RZOEMZYRKRBB", "热轧代工轧硬入库日报表"),
    YCSJRBB("YCSJRBB","异常数据日报表"),
    SJPCRBBCG("SJPCRBBCG", "锁价排产(常规)日报表"),
    SJPCRBBTG("SJPCRBBTG", "锁价排产(特规)日报表"),
    ROZPCRBB("ROZPCRBB", "热轧代工轧硬排产日报表"),
    RZCGFHKRBB("RZCGFHKRBB","热轧采购付款（货款）日报表"),
    RZCGFYFRBB("RZCGFYFRBB","热轧采购付款（运费）日报表"),
    LSCZYDRBB("LSCZYDRBB", "销售索价(轧硬)合同日报表"),
    LSCZDXRBB("LSCZDXRBB", "销售索价(镀锌)合同日报表"),
    TEERBB("TEERBB", "任务执行异常提醒日报表"),
    MANRDRBB("MANRDRBB", "客户欠款超期未归还日报表"),
    YMKCCOPY("YMKCCOPY", "库存结余月报表"),
    SWMR("SWMR", "停工月报表"),
    ZYXSKPQKB("ZYXSKPQKB", "轧硬销售开票情况月报表"),
    LJJGRBB("LJJGRBB", "拉矫警示日报表"),
    RDSQRBB("RDSQRBB","备件质量问题未处理日报表"),
    ZYSJSCTRBB("ZYSJSCTRBB", "销售(轧硬锁价)合同汇总日报表"),
    DXXSSCTRBB("DXXSSCTRBB", "销售(镀锌销售)合同汇总日报表"),
    SSS("SSS", "销售统计汇总"),
    FICTITIOUS_STOCK("FICTITIOUS_STOCK","虚拟库存"),
    SUSPEND("SUSPEND", "主料挂起超期日报表"),
    WeatherForecast("WeatherForecast","天气预报"),
    ;

    private String type;

    private String typeName;

    DynamicTaskName(String type, String typeName) {
        this.type = type;
        this.typeName = typeName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public static DynamicTaskName getEnum(String type) {
        if (type == null) {
            return null;
        }
        for (DynamicTaskName i : DynamicTaskName.values()) {
            if (i.getType().equals(type)) {
                return i;
            }
        }
        return null;
    }

    /**
     * 根据模糊名称 获取type集合
     */
    public static List<String> getLikeTypeNames( String likeName ){
        if( StringUtils.isEmpty( likeName ) ){
            return null;
        }
        List<String> types = new ArrayList<>();
        for( DynamicTaskName i : DynamicTaskName.values() ){
            if( i.getTypeName().trim().contains( likeName ) ){
                types.add( i.getType() );
            }
        }
        if( CollectionUtil.isNotEmpty( types ) ){
            return types;
        }
        return null;
    }

}
